package com.itheima.Demo;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Demo04Map的遍历 {
    public static void main(String[] args) {
        //创建对象;
        Map<String,String> map = new HashMap<>();
        map.put("大鹏","柳岩");
        map.put("罗志祥","周扬青");
        map.put("小岳岳","孙越");
        //entrySet()键值对方法
        //能够把键值对当做是一个对象变成Set集合
        Set<Map.Entry<String, String>> set = map.entrySet();
        //增强for遍历set
        for (Map.Entry<String, String> s1 : set) {
            //获取键
            String key = s1.getKey();
            String value = s1.getValue();
            System.out.println(key+"="+value);
        }
    }
}
